<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jQuery.min.js"></script>
</head>

<body>
    <script>
        var obj = {
            msg: {
                sex: '男'
            }
        };
        var obj2 = {
            id: 1,
            name: 'hu',
            msg: {
                age: 18
            }
        }
        // console.log(obj2);
        // $.extend(obj, obj2);//后者拷贝给前者 默认浅拷贝 复杂数据类型浅拷贝是拷贝地址 会覆盖 会影响
        // obj.msg.age = 20;
        // console.log(obj);

        console.log(obj2);
        $.extend(true, obj, obj2);//后者拷贝给前者  深拷贝 不会互相影响
        obj.msg.age = 20;
        console.log(obj);

    </script>
</body>

</html>